import type { WebsiteConfigReturn } from '@/apis/model/system.ts'
interface IState {
  system_config: WebsiteConfigReturn
}
export const state = reactive<IState>({
  system_config: {}
})
const KEYS: Record<string, number> = {
  website: 1,
  seo: 2,
  contact: 3,
  agreement: 4,
  register: 5,
  email: 6,
  push: 7
}
const { request: getWebsiteConfig } = useRequest(websiteConfigApi)
// 获取系统配置
export const getSystemConfig = async (key: string) => {
  const res = await getWebsiteConfig({
    type: KEYS[key]
  })
  if (key === 'website') {
    const systemStore = useSystemStore()
    systemStore.updateSystemInfo(res)
  }
  state.system_config = res
}
